<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>04找出字符串中的所有数字</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
    </style>
</head>
<body>
	<div class="container">
		<h1>04找出字符串中的所有数字</h1>
	</div>
	<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
	<script type="text/javascript">
	var str='hello12 fff 87 er334 233 -=-=fa80你好';

	function findNums(str) {
		var one, tmp = [], numsArr = []
		for (var i = 0, len = str.length; i < len; i++) {
			one = str[i]

			if(one >= '0' && one <= '9') {
				tmp.push(one)
			} else {
				if(tmp.length) {
					numsArr.push(tmp.join(''))
					tmp = []
				}
			}
		}

		if(tmp.length) {
			numsArr.push(tmp.join(''))
		}

		return numsArr
	}
	console.log(findNums(str))
	</script>
</body>
</html>